#!/bin/bash
# author: qi3.wang@haiziwang.com

TOP_DIR=$(cd $(dirname "$0") && pwd)
INVENTORY_FILE=host
# INVENTORY_FILE=newhost.yml

cd $TOP_DIR

install_zoo(){
    echo "Start Install Zookeeper"
    ansible-playbook -i inventory/$INVENTORY_FILE role_zoo.yml
}

install_kafka(){
    echo "Start Install Kafka"
    ansible-playbook -i inventory/$INVENTORY_FILE role_kafka.yml
}

install_es(){
    echo "Start Install ElasticSearch"
    ansible-playbook -i inventory/$INVENTORY_FILE role_es.yml
}

install_filebeat(){
    echo "Start Install Filebeat"
    ansible-playbook -i inventory/$INVENTORY_FILE role_filebeat.yml
}

install_kibana(){
    echo "Start Install Kibana"
    ansible-playbook -i inventory/$INVENTORY_FILE role_kibana.yml
}

install_cerebro(){
    echo "Start Install Cerebro"
    ansible-playbook -i inventory/$INVENTORY_FILE role_cerebro.yml
}

install_logstash(){
    echo "Start Install Logstash"
    ansible-playbook -i inventory/$INVENTORY_FILE role_logstash.yml
}

install_esdn(){
    echo "Start Install ElasticSearch"
    ansible-playbook -i inventory/$INVENTORY_FILE role_esDataNew.yml
}

case $1 in
    "install_zoo")
    install_zoo
    ;;
    "install_kafka")
    install_kafka
    ;;
    "install_es")
    install_es
    ;;
    "install_filebeat")
    install_filebeat
    ;;
    "install_kibana")
    install_kibana
    ;;
    "install_cerebro")
    install_cerebro
    ;;
    "install_logstash")
    install_logstash
    ;;
    "install_esdn")
    install_esdn
    ;;
    "test")
    test
    ;;
    *)
    echo "------------------------------------------------------------------------"
    echo "Enter install_zoo:                Install Zookeeper"
    echo "Enter install_kafka:              Install Kafka"
    echo "Enter install_es:                 Install ElasticSearch"
    echo "Enter install_filebeat:           Install Filebeat"
    echo "Enter install_kibana:             Install Kibana"
    echo "Enter install_cerebro:            Install Cerebro"
    echo "Enter install_logstash:           Install Logstash"
    echo "Enter install_esdn:               Install ElasticSearch Data NEW"
    echo "Enter test:                       TEST"
    echo "------------------------------------------------------------------------"
    ;;
esac
